package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.Compensation;
import cn.wolfcode.crm.domain.Paymen;
import cn.wolfcode.crm.domain.Task;
import cn.wolfcode.crm.query.PaymenQueryObject;
import cn.wolfcode.crm.query.TaskQueryObject;
import cn.wolfcode.crm.service.IPaymenService;
import cn.wolfcode.crm.service.ITaskService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by Administrator on 2018/6/12.
 */

@Controller
@RequestMapping("paymen")
public class PaymenController {

    @Autowired
    private IPaymenService paymenService;


    @RequestMapping("view")
    @RequiresPermissions(value = {"paymen:view", "缴费页面"}, logical = Logical.OR)
    public String view() {
        return "paymen";
    }


    @RequestMapping("query")
    @ResponseBody
    @RequiresPermissions(value = {"paymen:query", "缴费列表"}, logical = Logical.OR)
    public PageResult query(PaymenQueryObject qo) {
        return paymenService.query(qo);
    }

    @RequestMapping("saveOrUpdate")
    @ResponseBody
    @RequiresPermissions(value = {"paymen:saveOrUpdate", "缴费处理"}, logical = Logical.OR)
    public JsonResult saveOrUpdate(Paymen paymen) {
        try {
            paymenService.pay(paymen);
            return JsonResult.success("");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.mark("保存失败");
        }
    }




}